package com.cswangdao.service.impl;

import com.cswangdao.domain.dto.FootprintDTO;
import com.cswangdao.domain.model.MarketFootprint;
import com.cswangdao.mapper.MarketFootprintMapper;
import com.cswangdao.result.PageResult;
import com.cswangdao.service.FootprintService;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class FootprintServiceImpl implements FootprintService {
    @Autowired
    private MarketFootprintMapper footprintMapper;

    @Override
    public PageResult<MarketFootprint> pageQueryInfo(FootprintDTO pageDTO) {
        try/*(SqlSession sqlSession = MybatisUtil.getSqlSession(true)) */{
         //   MarketFootprintMapper footprintMapper = sqlSession.getMapper(MarketFootprintMapper.class);
            PageHelper.startPage(pageDTO.getPage(),pageDTO.getLimit());
            Page<MarketFootprint> footprintPage = footprintMapper.pageQueryInfo(pageDTO);
            PageResult<MarketFootprint> result = PageResult.result(footprintPage);
            return result;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
